local hx__bingdongli = fk.CreateSkill{
    name = "hx__bingdongli",

    tags = {Skill.Compulsory},
}

fk.MagicDamage = 8
Fk:addDamageNature(fk.MagicDamage, "magic_damage", true)

hx__bingdongli:addEffect(fk.BeforeHpChanged,{
  can_refresh = function(self, event, target, player, data)
    return player == target and data.damageEvent and data.damageEvent.damageType == fk.MagicDamage
  end,
  on_refresh = function (self, event, target, player, data)
    data.num = data.num - data.shield_lost
    data.shield_lost = 0
    --player.room:broadcastPlaySound("./packages/moepack/audio/card/charm_damage")
    player.room:delay(200)
  end,
})

hx__bingdongli:addEffect(fk.DamageInflicted,{
    can_trigger = function (self, event, target, player, data)
        return player:hasSkill(hx__bingdongli.name) and target and target == player 
    end,
    on_cost = function (self, event, target, player, data)
        if player:usedSkillTimes("hx__bingjiyuan",Player.HistoryGame) == 0 then
            return data.damage and data.damageType == fk.NormalDamage
        else
            return data.damage and data.damageType ~= fk.FireDamage    
        end
    end,
    on_use = function (self, event, target, player, data)
        data:preventDamage()
    end,
})

hx__bingdongli:addEffect(fk.DamageCaused,{
    can_trigger = function (self, event, target, player, data)
        return player:hasSkill(hx__bingdongli.name) and target and target == player 
    end,
    on_cost = function (self, event, target, player, data)
        if player:usedSkillTimes("hx__bingjiyuan",Player.HistoryGame) == 0 then
            return not data.to:isNude()
        else
            return true
        end
    end,
    on_use = function (self, event, target, player, data)
        if player:usedSkillTimes("hx__bingjiyuan",Player.HistoryGame) == 0 then
            data.to:throwAllCards("he",hx__bingdongli.name)
            data:preventDamage()
        else
            data.damageType = fk.MagicDamage
            local num = data.damage * 2
            data:changeDamage(num)
        end
    end,
})


return hx__bingdongli